var crypto = require('crypto');

module.exports = {
	result : function(status, data, errmsg) {
		var ret = {};
		ret['status'] = status;
		if (data) {
			ret['data'] = data;
		};
		if (errmsg) {
			ret['errmsg'] = errmsg;
		};
		return ret;
	},
	md5 : function (text) {
		text = text.toString();
		return crypto.createHash('md5').update(text).digest('hex');
	},
	sha1 : function (text) {
		text = text.toString();
		return crypto.createHash('sha1').update(text).digest('hex');
	},
	umd5 : function (text) {
		text = text.toString();
		return this.md5(this.sha1(text) + C.data_auth_key);
	},
	now : function () {
		return Date.parse(new Date())/1000;
	}
}